home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MacWorld 1997 August
/
Macworld (1997-08).dmg
/
Serious Demos
/
Crimson Demo
/
Crimson Demos
/
Customer File
/
CustFrmCode
< prev
next >
Wrap
Text File
|
1997-06-17
|
3KB
|
138 lines
Procedure NextBtn.Click()
Inc CurrentRecord
If Populate_CustForm(CurrentRecord)=False
Dec CurrentRecord
Endif
Return
Procedure PrevBtn.Click()
Dec CurrentRecord
If CurrentRecord>0
If Populate_CustForm(CurrentRecord)=False
Inc CurrentRecord
Endif
Endif
Return
Procedure AddBtn.Click()
Do Case
Case Mode={Q}
CustNo.Value=Str(NextFreeRec)
CustName.Value=""
CustAddr.Value=""
CustPhone.Value=""
CustFax.Value=""
CustEmail.Value=""
CustLocn.Value=1
NextBtn.Enabled=False
PrevBtn.Enabled=False
AddBtn.Caption="Save"
UpdateBtn.Caption="Cancel"
LocateBtn.Enabled=False
QuitBtn.Enabled=False
Mode={A}
Break
Case Mode={A}
Do Update_Record(NextFreeRec)
CurrentRecord=NextFreeRec
LocateForm.LBox.InsertRow(CurrentRecord,CustName.Value)
Inc NextFreeRec
NextBtn.Enabled=True
PrevBtn.Enabled=True
AddBtn.Caption="Add"
UpdateBtn.Caption="Update"
LocateBtn.Enabled=True
QuitBtn.Enabled=True
Mode={Q}
Break
Case Mode={U}
Do Update_Record(CurrentRecord)
LocateForm.LBox.SetRow(CurrentRecord,CustName.Value)
NextBtn.Enabled=True
PrevBtn.Enabled=True
AddBtn.Caption="Add"
UpdateBtn.Caption="Update"
LocateBtn.Enabled=True
QuitBtn.Enabled=True
Mode={Q}
Endcase
Return
Procedure UpdateBtn.Click()
If Mode={Q}
NextBtn.Enabled=False
PrevBtn.Enabled=False
AddBtn.Caption="Save"
UpdateBtn.Caption="Cancel"
LocateBtn.Enabled=False
QuitBtn.Enabled=False
Mode={U}
Else
NextBtn.Enabled=True
PrevBtn.Enabled=True
AddBtn.Caption="Add"
UpdateBtn.Caption="Update"
LocateBtn.Enabled=True
QuitBtn.Enabled=True
Mode={Q}
Endif
Return
Procedure LocateBtn.Click()
LocateForm.ShowWindow
Return
Procedure QuitBtn.Click()
Close #1
End
Return
Function Populate_CustForm(RecNo) Returning Integer Public
Parameter RecNo As Integer
Local CustStruct As Structure
Local Cust_no As Integer
Local Cust_name As String [30]
Local Cust_addr As String [255]
Local Cust_phone As String [16]
Local Cust_fax As String [16]
Local Cust_email As String [30]
Local Cust_location As Integer
Endstruct
Get #1,RecNo,CustStruct
If ERR
Return False
Endif
CustNo.Value=Str(Cust_no)
CustName.Value=Cust_name
CustAddr.Value=Cust_addr
CustPhone.Value=Cust_phone
CustFax.Value=Cust_fax
CustEmail.Value=Cust_email
CustLocn.Value=Cust_Location
Return True
Procedure Update_Record(RecNo)
Parameter RecNo As Integer
Local CustStruct As Structure
Local Cust_no As Integer
Local Cust_name As String [30]
Local Cust_addr As String [255]
Local Cust_phone As String [16]
Local Cust_fax As String [16]
Local Cust_email As String [30]
Local Cust_location As Integer
Endstruct
Cust_no=RecNo
Cust_name=CustName.Value
Cust_addr=CustAddr.Value
Cust_phone=CustPhone.Value
Cust_fax=CustFax.Value
Cust_email=CustEmail.Value
Cust_Location=CustLocn.Value
Put #1,RecNo,CustStruct
Return